/* eslint-disable */
import { SingleTableMixins } from '@/mixins/SingleTableMixins'
import Pagination from '@/components/Pagination'
import {ajaxGetDictItems,getDictItemsFromCache} from '@/api/api'
import AssetViewModal from '../../assetBusiness/modules/AssetViewModal'

export default {
  mixins: [ SingleTableMixins ],
  components: {Pagination, AssetViewModal},
  data() {
    return {
      disableMixinCreated:true,
      url:{
        list: `/asset/list`
      },
      currentRow: null,
      // 大楼列表
      imgList:[
      ],
      buildingTableData:[], // 楼层数据
      buildingName:'', // 大楼名称
    }
  },
  mounted() {
    // 默认腾飞大厦A
    this.loadBulding();
  },
  methods: {
    loadBulding(){
      let that = this;
      //根据字典Code, 初始化字典数组
      ajaxGetDictItems("building", null).then((res) => {
        if (res.success) {
          this.imgList = res.data.map(item => {
            if(!isNaN(that.trim(item.value))){
              item.value = parseInt(that.trim(item.value));
            }
            return item;
          })
          this.setCurrent( this.imgList[0]);
        }
      })
    },
    // 切换大楼显示楼层
    setCurrent(row) {
      this.$refs.singleTable.setCurrentRow(row);
    },
    handleCurrentChange(val) {
      this.searchModel.locationBuilding = val.value;
      this.loadData(1);
    },
    trim (str) {
      if(str){
        str =  str.toString();
        str = str.replace(/(^\s*)|(\s*$)/g, "");
        if(str && str != 0 && str.charCodeAt() == 0){
          str = ''
        }
        return str;
      }
      return "";
    },
  }
}
